<?php

/*
 *    Document   : login
 *   Created on : Jun 11, 2011, 3:23:34 PM
 *    Author     : ClarkT AKA FalleN
 *    Company    : Amodity
 *    Web        : http://www.amodity.com
 *    Copyright  : 2011
 */

/*
 *  Admin Login Function
 */

class Login extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library('auth');
        $this->load->model('admin/core');
        $this->core->_prev_url();
        $this->load->helper('config_file');
    }

    function index() {
        $this->template->set('title', lang('g_login'));
        $this->template->load('templates/admin_login_template', 'admin_login', null, 'admin');
    }

    function validate() {
        $username = $this->input->post('username');
        $password = $this->input->post('password');
        if ($this->auth->login($username, $password)) {
            redirect('admin');
        } else {
            $this->message->set('warning', lang('g_incorrect_login'));
            $this->session->set_flashdata(array('error' => 'true'));
            redirect('admin/login');
        }
    }

}

?>